# 导入request库
import requests
# 创建
sess = (
    requests.session())
# 定义全局变量ip
ip = "192.168.1.59"

# 定义函数发送get请求
def restful_get():
    i = input("请输入手机id:")
    rp = sess.request("get","http://"+ip+f":8080/pinter/com/phone/{i}")
    print(rp.text)
def restful_post():
    post = {"brand":"Huawei","color":"yellow","memorySize":"64G","cpuCore":"8核","price":"8848","desc":"全新上市"}
    rp = sess.request("post","http://"+ip+f":8080/pinter/com/phone",json = post)
    print(rp.text)
def restful_put():
    post = {"brand":"Huawei","color":"yellow","memorySize":"64G","cpuCore":"8核","price":"8848","desc":"全新上市"}
    rp = sess.request("put","http://"+ip+f":8080/pinter/com/phone",json = post)
    print(rp.text)
def restful_delete():
    post = {"brand":"Huawei","color":"yellow","memorySize":"64G","cpuCore":"8核","price":"8848","desc":"全新上市"}
    rp = sess.request("delete","http://"+ip+f":8080/pinter/com/phone",json = post)
    print(rp.text)
if __name__ == '__main__':
    restful_get()
    restful_post()
    restful_put()
    restful_delete()